﻿/*
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/

Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations
under the License.
*/
package com.jorritdevries.console
{
	import flash.events.Event;

	/**
	 * A ConsoleMessageEvent is dispatched by the Console class when
	 * the calls Console.print(message, colour).
	 * @author jorrit@jorritdevries.com
	 */
	public class ConsoleMessageEvent extends Event
	{
		/**
		 * Defines the value of the type property of a console message event object.
		 */
		public static const MESSAGE:String = "message";
		
		private var mMessage:String;
		private var mColour:uint;
		
		/**
		 * Creates a new ConsoleMessageEvent with the specified parameters.
		 * @param type The type of the event, accessible as <code>Event.type</code>.
		 * @param message The message that is requested to be displayed.
		 * @param colour The colour in which the message should be displayed, if possible.
		 * @param bubbles Determines whether the Event object participates in the
		 * bubbling stage of the event flow.
		 * @param cancelable Determines whether the Event object can be canceled.
		 */
		public function ConsoleMessageEvent(type:String, message:String = "", colour:uint = 0x000000,
			bubbles:Boolean = false, cancelable:Boolean = false)
		{
			super(type, bubbles, cancelable);
			mMessage = message;
			mColour = colour;
		}
		
		/**
		 * @see http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/Event.html#clone()
		 */
		public override function clone():Event
		{
			return new ConsoleMessageEvent(type, message, colour, bubbles, cancelable);
		}
		
		/**
		 * The message that is requested to be displayed.
		 */
		public function get message():String
		{
			return mMessage;
		}
		
		/**
		 * The colour in which the message should be displayed, if possible.
		 */
		public function get colour():uint
		{
			return mColour;
		}
		
		/**
		 * @see http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/Event.html#toString()
		 */
		public override function toString():String
		{
			return formatToString("ConsoleMessageEvent", "type", "message", "colour", "bubbles",
				"cancelable", "eventPhase");
		}
	}
	
}